<?php
/**
 * Created by PhpStorm.
 * User: zhaobl
 * Date: 2017\11\9 0009
 * Time: 14:01
 */
namespace System;
class Start {
    static function autoload($className)
    {
        $file = str_replace('\\','/',$className.'.php');
        if(file_exists($file)){
            include_once $file;
        }
    }

    static function start()
    {
        spl_autoload_register('self::autoload');
        new Exceptions();
        new Input();

        $Uri = new Router();

        $file = HOME_PATH.$Uri->class.'.php';

        if(file_exists($file)){
            include_once $file;
            $c = '\App\\Controller\\'.$Uri->class;
            if(class_exists($c)){
                $class = new $c();
                if(method_exists($class,$Uri->action)){
                    call_user_func_array([$class,$Uri->action],[]);
                    exit;
                }
            }
        }
        s_show_error('Sorry, the page you are looking for could not be found.',404,'File Not Found');
    }
}